package com.forekonw.demo8;

public class Demo {

    public static void main(String[] args) {
        Pet[] p = new Pet[3];
        //怎么给数组添加元素
        Pet p1 = new Dog();
        Penguin p2 = new Penguin();
        p[0]= p1;
        p[1]= p2;
        //从数组中获取元素
        //Dog dogs = (Dog) p[0];
        Pet pet = p[0];//dog
        Pet pet1 = p[1];//penguin
        //都是继承于父类
    }
}
